package com.devilvan.betrice.poetry.controller;

import com.devilvan.betrice.common.BetriceResultVo;
import com.devilvan.betrice.poetry.po.PoetryKeywordPo;
import com.devilvan.betrice.poetry.service.PoetryKeywordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Evad.Wu
 * @Description 古诗文网-关键字分类信息表 控制器
 * @date 2022-11-29
 */
@RestController
@RequestMapping(value = "poetryKeywordController")
@Tag(name = "古诗文网-关键字分类信息表 控制器")
public class PoetryKeywordController {
    @Resource(name = "poetryKeywordServiceImpl")
    private PoetryKeywordService poetryKeywordService;

    /**
     * 总请求控制器
     *
     * @return 形式返回
     */
    @Operation(summary = "总请求控制器")
    @GetMapping(value = "doPoetryKeyword")
    public BetriceResultVo<PoetryKeywordPo> doPoetryKeyword() {
        BetriceResultVo<PoetryKeywordPo> betriceResultVo = new BetriceResultVo<>();
        return betriceResultVo;
    }

    /**
     * 采集报文控制器
     *
     * @return 形式返回
     */
    @Operation(summary = "采集报文控制器")
    @GetMapping(value = "doPoetryKeywordCrawler")
    public BetriceResultVo<PoetryKeywordPo> doPoetryKeywordCrawler() {
        return poetryKeywordService.doPoetryKeywordCrawler();
    }

    /**
     * 测试；网页源码采集
     */
    @Operation(summary = "测试；网页源码采集")
    @GetMapping(value = "doPoetryKeywordParser")
    public void doPoetryKeywordParser() {
        poetryKeywordService.doPoetryKeywordParser();
    }

    /**
     * 根据关键字查询并采集
     *
     * @param keyword 查询的关键字
     * @return 形式返回
     */
    @Operation(summary = "根据关键字查询并采集")
    @GetMapping(value = "doPoetryByKeyword")
    public BetriceResultVo<PoetryKeywordPo> doPoetryByKeyword(@RequestParam @NonNull String keyword) {
        return poetryKeywordService.doPoetryByKeyword(keyword);
    }
}
